package com.ezjie.ielts.task;

import java.util.HashMap;
import java.util.Map;

import android.content.Context;

import com.ezjie.ielts.constant.Constants;
import com.ezjie.ielts.core.http.HttpAPI;
import com.ezjie.ielts.core.http.HttpRequestCallBack;
import com.ezjie.ielts.core.http.ServerInterfaceDefinition;

public class ReadClassifyTask {

	private Context context;

	public ReadClassifyTask(Context context) {
		this.context = context;
	}

	/**
	 * 获取阅读题型分类列表
	 * 
	 * @param httpRequestCallBack
	 */
	public void getReadClassifyInfo(HttpRequestCallBack httpRequestCallBack) {
		Map<String, String> params = new HashMap<String, String>();

		HttpAPI.getInstance(context).doGetRequest(ServerInterfaceDefinition.OPT_READ_CLASSIFY, params,
				httpRequestCallBack);
	}

	/**
	 * 根据类型 获取题目
	 * 
	 * @param type
	 * @param httpRequestCallBack
	 */
	public void getReadClassifyQuestion(String type, HttpRequestCallBack httpRequestCallBack) {
		Map<String, String> params = new HashMap<String, String>();
		params.put(Constants.PARAMS_TYPE, type);

		HttpAPI.getInstance(context).doGetRequest(ServerInterfaceDefinition.OPT_READ_CLASSIFY_QUESTION, params,
				httpRequestCallBack);
	}

	/**
	 * 提交阅读分类练习
	 * 
	 * @param type
	 * @param questions
	 * @param position
	 * @param httpRequestCallBack
	 */
	public void submitReadClassifyAnswer(String type, String questions, String position,
			HttpRequestCallBack httpRequestCallBack) {

		Map<String, String> params = new HashMap<String, String>();
		params.put(Constants.PARAMS_TYPE, type);
		params.put(Constants.PARAMS_QUESTIONS, questions);
		params.put(Constants.PARAMS_POSITION, position);

		HttpAPI.getInstance(context).doPostRequest(ServerInterfaceDefinition.OPT_READ_CLASSIFY_QUESTION, params,
				httpRequestCallBack);

	}

	/**
	 * 提交阅读练习
	 * 
	 * @param category_id
	 * @param questions
	 * @param httpRequestCallBack
	 */
	public void submitReadAnswer(String category_id, String questions, HttpRequestCallBack httpRequestCallBack) {

		Map<String, String> params = new HashMap<String, String>();
		params.put(Constants.PARAMS_CATEGORY_ID, category_id);
		params.put(Constants.PARAMS_QUESTIONS, questions);

		HttpAPI.getInstance(context).doPostRequest(ServerInterfaceDefinition.OPT_READ_CLASSIFY_QUESTION, params,
				httpRequestCallBack);

	}

	/**
	 * 提交听力练习
	 * 
	 * @param category_id
	 * @param questions
	 * @param httpRequestCallBack
	 */
	public void submitListenAnswer(String category_id, String questions, HttpRequestCallBack httpRequestCallBack) {

		Map<String, String> params = new HashMap<String, String>();
		params.put(Constants.PARAMS_CATEGORY_ID, category_id);
		params.put(Constants.PARAMS_QUESTIONS, questions);

		HttpAPI.getInstance(context).doPostRequest(ServerInterfaceDefinition.OPT_LISTEN_CLASSIFY_QUESTION, params,
				httpRequestCallBack);

	}

}
